package com.example.basicdemo.service.impl;

import com.example.basicdemo.model.builder.*;
import com.example.basicdemo.model.request.*;
import com.example.basicdemo.model.response.*;
import com.example.basicdemo.model.result.*;
import com.example.basicdemo.service.PermissionService;
import com.isyscore.os.dev.api.http.AbstractIsyscoreClient;
import com.isyscore.os.dev.api.http.IsyscoreClient;
import com.isyscore.os.dev.util.IsyscoreUtils;

//@Service
public class PermissionServiceImpl implements PermissionService {

    private IsyscoreClient client;

    public PermissionServiceImpl(IsyscoreClient client) {
        this.client = client;
    }

    /**
     * 查询组织信息树
     *
     * @param builder
     * @return
     */
    @Override
    public QueryRentalInfoResult queryRentalInfo(QueryRentalInfoRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryRentalInfoRequest request = new QueryRentalInfoRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
//        request.putOtherTextParam("rentalId", builder.getRentalId());
//        request.putOtherTextParam("rentTypeId", builder.getRentTypeId());
//        request.putOtherTextParam("isValid", builder.getValid());
        //调用接口
        QueryRentalInfoResponse response = (QueryRentalInfoResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryRentalInfoResult result = new QueryRentalInfoResult(response);

        //业务处理

        return result;
    }

    /**
     * 查询组织信息详情
     *
     * @param builder
     * @return
     */
    @Override
    public QueryRentalInfoDetailResult queryRentalInfoDetail(QueryRentalInfoDetailRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryRentalInfoDetailRequest request = new QueryRentalInfoDetailRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
//        request.putOtherTextParam("rentalId", builder.getRentalId());

        //调用接口
        QueryRentalInfoDetailResponse response = (QueryRentalInfoDetailResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryRentalInfoDetailResult result = new QueryRentalInfoDetailResult(response);

        //业务处理

        return result;
    }

    /**
     * 查询下级组织列表
     *
     * @param builder
     * @return
     */
    @Override
    public QueryRentalInfoChildResult queryRentalInfoChild(QueryRentalInfoChildRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryRentalInfoChildRequest request = new QueryRentalInfoChildRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
//        request.setPathValue(String.valueOf(builder.getRentalId()));
//        request.putOtherTextParam("codeOrName", builder.getCodeOrName());
//        request.putOtherTextParam("pageNo", builder.getPageNo());
//        request.putOtherTextParam("pageSize", builder.getPageSize());
////        request.putOtherTextParam("rentalId", builder.getRentalId());
//        request.putOtherTextParam("isValid", builder.getValid());

        //调用接口
        QueryRentalInfoChildResponse response = (QueryRentalInfoChildResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryRentalInfoChildResult result = new QueryRentalInfoChildResult(response);

        //业务处理

        return result;
    }

    /**
     * 获取子孙节点信息
     *
     * @param builder
     * @return
     */
    @Override
    public GetRentalChildResult getRentalChild(GetRentalChildRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        GetRentalChildRequest request = new GetRentalChildRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("rentalId", builder.getRentalId());
        request.putOtherTextParam("type", builder.getType());

        //调用接口
        GetRentalChildResponse response = (GetRentalChildResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        GetRentalChildResult result = new GetRentalChildResult(response);

        //业务处理

        return result;
    }

    /**
     * 新增组织信息
     *
     * @param builder
     * @return
     */
    @Override
    public SaveRentalInfoResult saveRentalInfo(SaveRentalInfoRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        SaveRentalInfoRequest request = new SaveRentalInfoRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
//        request.setBizModel(builder.getBizDomain());
//        request.putOtherTextParam("address", builder.getAddress());
//        request.putOtherTextParam("email", builder.getEmail());
//        request.putOtherTextParam("phone", builder.getPhone());
//        request.putOtherTextParam("postalCode", builder.getPostalCode());
//        request.putOtherTextParam("rentalRemark", builder.getRentalRemark());
//        request.putOtherTextParam("roleId", builder.getRoleId());
//        request.putOtherTextParam("userName", builder.getUserName());
        //调用接口
        SaveRentalInfoResponse response = (SaveRentalInfoResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        SaveRentalInfoResult result = new SaveRentalInfoResult(response);

        //业务处理

        return result;
    }

    /**
     * 修改组织信息
     *
     * @param builder
     * @return
     */
    @Override
    public UpdateRentalInfoResult updateRentalInfo(UpdateRentalInfoRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        UpdateRentalInfoRequest request = new UpdateRentalInfoRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
//        request.setBizModel(builder.getBizDomain());
//        request.putOtherTextParam("address", builder.getAddress());
//        request.putOtherTextParam("email", builder.getEmail());
//        request.putOtherTextParam("phone", builder.getPhone());
//        request.putOtherTextParam("postalCode", builder.getPostalCode());
//        request.putOtherTextParam("rentalRemark", builder.getRentalRemark());
//        request.putOtherTextParam("roleId", builder.getRoleId());
//        request.putOtherTextParam("userName", builder.getUserName());

        //调用接口
        UpdateRentalInfoResponse response = (UpdateRentalInfoResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        UpdateRentalInfoResult result = new UpdateRentalInfoResult(response);

        //业务处理

        return result;
    }

    /**
     * 修改组织状态
     *
     * @param builder
     * @return
     */
    @Override
    public SwitchRentalStatusResult switchRentalStatus(SwitchRentalStatusRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        SwitchRentalStatusRequest request = new SwitchRentalStatusRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("rentalId", builder.getRentalId());
        request.putOtherTextParam("isValid", builder.getValid());

        //调用接口
        SwitchRentalStatusResponse response = (SwitchRentalStatusResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        SwitchRentalStatusResult result = new SwitchRentalStatusResult(response);

        //业务处理

        return result;
    }

    /**
     * 删除组织信息
     *
     * @param builder
     * @return
     */
    @Override
    public DeleteRentalInfoResult deleteRentalInfo(DeleteRentalInfoRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        DeleteRentalInfoRequest request = new DeleteRentalInfoRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setPathValue(builder.getId().toString());

        //调用接口
        DeleteRentalInfoResponse response = (DeleteRentalInfoResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        DeleteRentalInfoResult result = new DeleteRentalInfoResult(response);

        //业务处理

        return result;
    }

    /**
     * 查询园区信息列表
     *
     * @param builder
     * @return
     */
    @Override
    public QueryParkInfoResult queryParkInfo(QueryParkInfoRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryParkInfoRequest request = new QueryParkInfoRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("type", builder.getType());

        //调用接口
        QueryParkInfoResponse response = (QueryParkInfoResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryParkInfoResult result = new QueryParkInfoResult(response);

        //业务处理

        return result;
    }

    /**
     * 查询组织类型列表
     *
     * @param builder
     * @return
     */
    @Override
    public QueryRentalTypeResult queryRentalType(QueryRentalTypeRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryRentalTypeRequest request = new QueryRentalTypeRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
//        request.putOtherTextParam("rentalTypeName", builder.getRentalTypeName());

        //调用接口
        QueryRentalTypeResponse response = (QueryRentalTypeResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryRentalTypeResult result = new QueryRentalTypeResult(response);

        //业务处理

        return result;
    }

    /**
     * 添加组织类型
     *
     * @param builder
     * @return
     */
    @Override
    public AddRentalTypeResult addRentalType(AddRentalTypeRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        AddRentalTypeRequest request = new AddRentalTypeRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setBizModel(builder.getBizModel());

        //调用接口
        AddRentalTypeResponse response = (AddRentalTypeResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        AddRentalTypeResult result = new AddRentalTypeResult(response);

        //业务处理

        return result;
    }

    /**
     * 修改组织类型
     *
     * @param builder
     * @return
     */
    @Override
    public UpdateRentalTypeResult updateRentalType(UpdateRentalTypeReqeustBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        UpdateRentalTypeReqeust request = new UpdateRentalTypeReqeust();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setBizModel(builder.getBizModel());

        //调用接口
        UpdateRentalTypeResponse response = (UpdateRentalTypeResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        UpdateRentalTypeResult result = new UpdateRentalTypeResult(response);

        //业务处理

        return result;
    }

    /**
     * 删除组织类型
     *
     * @param builder
     * @return
     */
    @Override
    public DeleteRentalTypeResult deleteRentalType(DeleteRentalTypeRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        DeleteRentalTypeRequest request = new DeleteRentalTypeRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("id", builder.getId());

        //调用接口
        DeleteRentalTypeResponse response = (DeleteRentalTypeResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        DeleteRentalTypeResult result = new DeleteRentalTypeResult(response);

        //业务处理

        return result;
    }

    @Override
    public QueryUserAclResult queryUserAcl(QueryUserAclRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryUserAclRequest request = new QueryUserAclRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setPathValue(builder.getAppCode());
        //调用接口
        QueryUserAclResponse response = (QueryUserAclResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryUserAclResult result = new QueryUserAclResult(response);

        //业务处理

        return result;
    }

    private String buildPathValue(String appCode, String ticket) {
        return appCode + "?ticket=" + ticket;
    }

    @Override
    public PageUserResult pageUser(PageUserRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        PageUserRequest request = new PageUserRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setBizModel(builder.getBizModel());
        //调用接口
        PageUserResponse response = (PageUserResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        PageUserResult result = new PageUserResult(response);

        //业务处理

        return result;
    }

    /**
     * 查询所有数据权限角色
     *
     * @param builder
     * @return
     */
    @Override
    public ListDataAuthRoleResult listDataAuthRole(ListDataAuthRoleRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        ListDataAuthRoleRequest request = new ListDataAuthRoleRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("appCode", builder.getAppCode());

        //调用接口
        ListDataAuthRoleResponse response = (ListDataAuthRoleResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        ListDataAuthRoleResult result = new ListDataAuthRoleResult(response);

        //业务处理

        return result;
    }

    /**
     * 查询所有功能角色
     *
     * @param builder
     */
    @Override
    public ListRoleAclResult listRoleAcl(ListRoleAclRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        ListRoleAclRequest request = new ListRoleAclRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }

        //调用接口
        ListRoleAclResponse response = (ListRoleAclResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        ListRoleAclResult result = new ListRoleAclResult(response);

        //业务处理

        return result;
    }

    /**
     * 操作系统桌面单点登录
     *
     * @param builder
     * @return
     */
    @Override
    public OsLoginResult osLogin(OsLoginRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        OsLoginRequest request = new OsLoginRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("loginName", builder.getLoginName());
        request.putOtherTextParam("password", builder.getPassword());
        //调用接口
        OsLoginResponse response = (OsLoginResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        OsLoginResult result = new OsLoginResult(response);

        //业务处理

        return result;
    }

    /**
     * 操作系统桌面用户登录状态
     *
     * @param builder
     * @return
     */
    @Override
    public OsLoginStatusResult osLoginStatus(OsLoginStatusRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        OsLoginStatusRequest request = new OsLoginStatusRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        //调用接口
        OsLoginStatusResponse response = (OsLoginStatusResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        OsLoginStatusResult result = new OsLoginStatusResult(response);

        //业务处理

        return result;
    }

    /**
     * 操作系统桌面用户登出
     *
     * @param builder
     * @return
     */
    @Override
    public OsLogoutResult osLogout(OsLogoutRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        OsLogoutRequest request = new OsLogoutRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        //调用接口
        OsLogoutResponse response = (OsLogoutResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        OsLogoutResult result = new OsLogoutResult(response);

        //业务处理

        return result;
    }

    /**
     * 分页查询数据角色
     *
     * @param builder
     * @return
     */
    @Override
    public PageDataAuthResult pageDataAuth(PageDataAuthRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        PageDataAuthRequest request = new PageDataAuthRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("aclName", builder.getAclName());
        request.putOtherTextParam("appCodes", builder.getAppCodes());
        request.putOtherTextParam("authName", builder.getAuthName());
        request.putOtherTextParam("gmtModified", builder.getGmtModified());
        request.putOtherTextParam("pageNo", builder.getPageNo());
        request.putOtherTextParam("pageSize", builder.getPageSize());
        //调用接口
        PageDataAuthResponse response = (PageDataAuthResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        PageDataAuthResult result = new PageDataAuthResult(response);

        //业务处理

        return result;
    }

    /**
     * 根据ID查询数据角色
     *
     * @param builder
     * @return
     */
    @Override
    public QueryDataAuthByIdResult queryDataAuthById(QueryDataAuthByIdRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryDataAuthByIdRequest request = new QueryDataAuthByIdRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("authId", builder.getAuthId());
        request.putOtherTextParam("appCode", builder.getAppCode());
        //调用接口
        QueryDataAuthByIdResponse response = (QueryDataAuthByIdResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryDataAuthByIdResult result = new QueryDataAuthByIdResult(response);

        //业务处理

        return result;
    }

    /**
     * 查询数据权限模块
     *
     * @param builder
     * @return
     */
    @Override
    public QueryDataAuthModuleResult queryDataAuthModule(QueryDataAuthModuleRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryDataAuthModuleRequest request = new QueryDataAuthModuleRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setPathValue(builder.getAppCode());
        //调用接口
        QueryDataAuthModuleResponse response = (QueryDataAuthModuleResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryDataAuthModuleResult result = new QueryDataAuthModuleResult(response);

        //业务处理

        return result;
    }

    /**
     * 根据角色id、应用标识查询权限
     *
     * @param builder
     * @return
     */
    @Override
    public QueryRoleAclByIdResult queryRoleAclById(QueryRoleAclByIdRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryRoleAclByIdRequest request = new QueryRoleAclByIdRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("roleId", builder.getRoleId());
        request.putOtherTextParam("appCode", builder.getAppCode());
        //调用接口
        QueryRoleAclByIdResponse response = (QueryRoleAclByIdResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryRoleAclByIdResult result = new QueryRoleAclByIdResult(response);

        //业务处理

        return result;
    }

    /**
     * 查询角色权限列表分页
     *
     * @param builder
     * @return
     */
    @Override
    public QueryRoleAclResult queryRoleAcl(QueryRoleAclRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryRoleAclRequest request = new QueryRoleAclRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setBizModel(builder.getBizModel());
        //调用接口
        QueryRoleAclResponse response = (QueryRoleAclResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryRoleAclResult result = new QueryRoleAclResult(response);

        //业务处理

        return result;
    }

    /**
     * 根据ID查询用户信息
     *
     * @param builder
     * @return
     */
    @Override
    public QueryUserByIdResult queryUserById(QueryUserByIdRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        QueryUserByIdRequest request = new QueryUserByIdRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("userId", builder.getUserId());
        request.putOtherTextParam("loginName", builder.getLoginName());
        //调用接口
        QueryUserByIdResponse response = (QueryUserByIdResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        QueryUserByIdResult result = new QueryUserByIdResult(response);

        //业务处理

        return result;
    }

    /**
     * 根据手机号重置用户密码
     *
     * @param builder
     * @return
     */
    @Override
    public ResetPasswordResult resetPassword(ResetPasswordRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        ResetPasswordRequest request = new ResetPasswordRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setPathValue(builder.getPhoneNumber());
        //调用接口
        ResetPasswordResponse response = (ResetPasswordResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        ResetPasswordResult result = new ResetPasswordResult(response);

        //业务处理

        return result;
    }

    /**
     * 新增数据角色
     *
     * @param builder
     * @return
     */
    @Override
    public SaveDataAuthResult saveDataAuth(SaveDataAuthRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        SaveDataAuthRequest request = new SaveDataAuthRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("acls", builder.getAcls());
        request.putOtherTextParam("name", builder.getName());
        request.putOtherTextParam("remark", builder.getRemark());
        request.putOtherTextParam("status", builder.getStatus());
        request.putOtherTextParam("type", builder.getType());
        //调用接口
        SaveDataAuthResponse response = (SaveDataAuthResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        SaveDataAuthResult result = new SaveDataAuthResult(response);

        //业务处理

        return result;
    }

    /**
     * 新增功能角色
     *
     * @param builder
     * @return
     */
    @Override
    public SaveRoleAclResult saveRoleAcl(SaveRoleAclRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        SaveRoleAclRequest request = new SaveRoleAclRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setBizModel(builder.getBizModel());
        //调用接口
        SaveRoleAclResponse response = (SaveRoleAclResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        SaveRoleAclResult result = new SaveRoleAclResult(response);

        //业务处理

        return result;
    }

    /**
     * 新增用户
     *
     * @param builder
     * @return
     */
    @Override
    public SaveUserResult saveUser(SaveUserRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        SaveUserRequest request = new SaveUserRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setBizModel(builder.getBizModel());
        //调用接口
        SaveUserResponse response = (SaveUserResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        SaveUserResult result = new SaveUserResult(response);

        //业务处理

        return result;
    }

    /**
     * 更新数据角色
     *
     * @param builder
     * @return
     */
    @Override
    public UpdateDataAuthResult updateDataAuth(UpdateDataAuthRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        UpdateDataAuthRequest request = new UpdateDataAuthRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("id", builder.getId());
        request.putOtherTextParam("name", builder.getName());
        request.putOtherTextParam("acls", builder.getAcls());
        request.putOtherTextParam("remark", builder.getRemark());
        //调用接口
        UpdateDataAuthResponse response = (UpdateDataAuthResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        UpdateDataAuthResult result = new UpdateDataAuthResult(response);

        //业务处理

        return result;
    }

    /**
     * 更新功能角色
     *
     * @param builder
     * @return
     */
    @Override
    public UpdateRoleAclResult updateRoleAcl(UpdateRoleAclRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        UpdateRoleAclRequest request = new UpdateRoleAclRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setBizModel(builder.getBizModel());
        //调用接口
        UpdateRoleAclResponse response = (UpdateRoleAclResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        UpdateRoleAclResult result = new UpdateRoleAclResult(response);

        //业务处理

        return result;
    }

    /**
     * 修改当前登录用户密码
     *
     * @param builder
     * @return
     */
    @Override
    public UpdateUserPasswordResult updateUserPassword(UpdateUserPasswordRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        UpdateUserPasswordRequest request = new UpdateUserPasswordRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.putOtherTextParam("password", builder.getPassword());
        //调用接口
        UpdateUserPasswordResponse response = (UpdateUserPasswordResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        UpdateUserPasswordResult result = new UpdateUserPasswordResult(response);

        //业务处理

        return result;
    }

    /**
     * 更新用户信息
     *
     * @param builder
     * @return
     */
    @Override
    public UpdateUserResult updateUser(UpdateUserRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        UpdateUserRequest request = new UpdateUserRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        request.setBizModel(builder.getBizModel());
        //调用接口
        UpdateUserResponse response = (UpdateUserResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        UpdateUserResult result = new UpdateUserResult(response);

        //业务处理

        return result;
    }


    /**
     * 获取所有学历信息
     *
     * @param builder
     * @return
     */
    @Override
    public GetAllDegreeResult getAllDegree(GetAllDegreeRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        GetAllDegreeRequest request = new GetAllDegreeRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        //调用接口
        GetAllDegreeResponse response = (GetAllDegreeResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        GetAllDegreeResult result = new GetAllDegreeResult(response);

        //业务处理

        return result;
    }

    /**
     * 获取所有公司信息
     *
     * @param builder
     * @return
     */
    @Override
    public GetAllLdapDeptResult getAllLdapDept(GetAllLdapDeptRequestBuilder builder) {
        //参数校验
        IsyscoreUtils.validateBuilder(builder);

        //获取请求对象
        GetAllLdapDeptRequest request = new GetAllLdapDeptRequest();
        if (builder.getHeaders() != null) {
            request.initHeaderParams(builder.getHeaders());
        }
        //调用接口
        GetAllLdapDeptResponse response = (GetAllLdapDeptResponse) IsyscoreUtils.getResponse(client, request);

        //结果封装
        GetAllLdapDeptResult result = new GetAllLdapDeptResult(response);

        //业务处理

        return result;
    }

    /**
     * 设置网关服务地址
     *
     * @param serverHost
     * @return
     */
    @Override
    public PermissionService setServerHost(String serverHost) {
        ((AbstractIsyscoreClient) this.client).setServerHost(serverHost);
        return this;
    }

}
